]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
authPrompt: Add ability to block authentication
authorIgnacy Kuchciński <ignacykuchcinski@gnome.org>
Tue, 2 Dec 2025 23:51:44 +0000 (00:51 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 14 Jan 2026 14:35:30 +0000 (14:35 +0000)
Make it possible to prevent the user from using the authentication
prompt, by showing the parental controls shield instead of the password
entry.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3980>

data/theme/gnome-shell-sass/widgets/_login-lock.scss
js/gdm/authPrompt.js

index b661e93c8d2aae131eb81efbd05a9d2300772fa7..d11d7224bc4f9e98f47e4d042a829ae7824ea8b1 100644 (file)
@@ -258,6 +258,21 @@ $_gdm_dialog_width: 25em;
   }
 }
 
+// Parental controls
+.parental-controls-shield {
+  spacing: 0.75em;
+
+  .parental-controls-shield-title {
+    margin-top: 0.6em;
+    @extend %title_4;
+    text-align: center;
+  }
+
+  .parental-controls-shield-description {
+    text-align: center;
+  }
+}
+
 // Notifications
 #unlockDialogNotifications {
   > .vhandle, > .hhandle {
index 2ad29b0e85112e815b5b72b98c39b76316048743..4a9e4f67b34e0d9f12ea5234906c931678f13b6c 100644 (file)
@@ -17,6 +17,33 @@ import {wiggle} from '../misc/animationUtils.js';
 
 const DEFAULT_BUTTON_WELL_ICON_SIZE = 16;
 const DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1000;
+
+// A widget displayed instead of the unlock prompt
+// when parental controls session limits are reached
+const ParentalControlsShield = GObject.registerClass(
+class ParentalControlsShield extends St.BoxLayout {
+    _init() {
+        super._init({
+            style_class: 'parental-controls-shield',
+            orientation: Clutter.Orientation.VERTICAL,
+            x_align: Clutter.ActorAlign.CENTER,
+        });
+
+        this._titleLabel = new St.Label({
+            style_class: 'parental-controls-shield-title',
+            text: _('Screen Time Limit Reached'),
+        });
+        this.add_child(this._titleLabel);
+
+        this._descriptionLabel = new St.Label({
+            style_class: 'parental-controls-shield-description',
+            text: _('Daily limit for screen time on this device has been reached. Resume tomorrow.'),
+        });
+        this._descriptionLabel.clutter_text.line_wrap = true;
+        this.add_child(this._descriptionLabel);
+    }
+});
+
 export const DEFAULT_BUTTON_WELL_ANIMATION_TIME = 300;
 
 export const MESSAGE_FADE_OUT_ANIMATION_TIME = 500;
@@ -102,6 +129,7 @@ export const AuthPrompt = GObject.registerClass({
             x_expand: true,
         });
         this.add_child(this._inputWell);
+        this._mainContent = this._inputWell;
 
         this._hasCancelButton = this._mode === AuthPromptMode.UNLOCK_OR_LOG_IN;
 
@@ -699,6 +727,25 @@ export const AuthPrompt = GObject.registerClass({
         this._entry.clutter_text.insert_unichar(unichar);
     }
 
+    /*
+     * Set whether to block the authentication with the parental controls shield.
+     *
+     * @param {boolean} shouldBlock Whether to block the authentication
+     */
+    setAuthBlocked(shouldBlock) {
+        if (!this._parentalControlsShield)
+            this._parentalControlsShield = new ParentalControlsShield();
+
+        const newMainContent = shouldBlock
+            ? this._parentalControlsShield
+            : this._inputWell;
+
+        if (newMainContent !== this._mainContent) {
+            this.replace_child(this._mainContent, newMainContent);
+            this._mainContent = newMainContent;
+        }
+    }
+
     begin(params) {
         params = Params.parse(params, {
             userName: null,